<template>
  <div>
    聊天相关混合
  </div>
</template>

<script>
export default {
  name: 'aboutChat',
  components: {},
  props: {},
  data: () => {
    return {};
  },
  computed: {},
  methods: {
    format: function(item) {
      // let objAction = {
      //   send:'发送消息',
      //   recall:'撤回消息',
      //   switch:'切换企业日志',
      // }
      let 发送方 = this._.get(item, 'sfrom');
      let 接收方 = (() => {
        let t = this._.get(item, 'tolist');
        if (t == null) {
          t = '';
        }
        return t.split(',');
      })();
      let exuid =
        this._.get(this, 'tempData.external_userid', false) ||
        this._.get(this, 'rfInfo.external_userid', '');
      let is对方发出 = exuid == 发送方 || this._.get(item, 'type', 0) == 1;
      let msgType = this._.get(item, 'msgtype', 'text');
      let content = (type => {
        if (type == 'text') {
          return { content: this._.get(item, 'content', '') };
        }
        if (['image', 'emotion'].includes(type)) {
          return {
            media_id: this._.get(item, 'sdkfileid', ''),
            imgUrl: this._.get(item, 'mediaUrl', ''),
          };
        }
        if (type == 'video') {
          return {
            media_id: this._.get(item, 'sdkfileid', ''),
            title: this._.get(item, 'title', ''),
            description: this._.get(item, 'description', ''),
            imgUrl: this._.get(item, 'imgUrl', ''),
            fileUrl: this._.get(item, 'mediaUrl', ''),
          };
        }
        if (type == 'file') {
          return {
            media_id: this._.get(item, 'sdkfileid', ''),
            fileUrl: this._.get(item, 'mediaUrl', ''),
          };
        }
        if (type == 'mpnews') {
          return {
            // articles: [
            //   {
            //     media_id: this._.get(item, "sdkfileid", ""),
            //     title: this._.get(item, "content", ""),
            //     description: this._.get(item, "content", ""),
            //     imgUrl: this._.get(item, "content", ""),
            //     fileUrl: this._.get(item, "content", ""),
            //   },
            // ],
          };
        }
        if (type == 'link') {
          return {
            title: this._.get(item, 'title', '未知链接'),
            description: this._.get(item, 'description', '未知概述'),
            url: this._.get(item, 'content', ''),
            picurl: this._.get(item, 'picurl', ''),
          };
        }
        if (['voice', 'meeting_voice_call'].includes(type)) {
          return {
            media_id: this._.get(item, 'sdkfileid', ''),
            fileUrl: this._.get(item, 'mediaUrl', ''),
            format: this._.get(item, 'content', ''),
          };
        }
      })(msgType);
      return {
        id: this._.get(item, 'id', ''),
        cusName: this._.get(this.tempData, 'remark'),
        face: this._.get(this.tempData, 'avatar'),
        消息id: this._.get(item, 'msgid', ''),
        动作: this._.get(item, 'action'),
        发送方: 发送方,
        发送方Name: this._.get(item, 'sfromName'),
        is对方发出: is对方发出,
        // type: this._.get(item, "type"),
        接收方: 接收方,
        群id: this._.get(item, 'roomid', null),
        msgTime: this._.get(item, 'msgTime'),
        msgType: msgType,
        content: content,
        // "sdkfileid": null,String	媒体资源的id信息。String类型
        // "md5sum": null,String	资源的md5值，供进行校验。String类型
        // "filesize": null,Integer	资源的文件大小。Uint32类型
        // "voiceSize": null,Long	语音消息大小
        // "playLength": null,Long	播放长度
        // "mediaUrl": null,String	媒体url
        // "corpId": "ww148b267da66793a8",String	企业微信corpId
        发送时间: this._.get(item, 'sendTime'),
      };
    },
  },
  mounted() {},
};
</script>
<style lang="scss" scoped></style>
